/**
*      author: Y_Yao
*      created: 2025-03-12 20:58:54
**/

#include<bits/stdc++.h>

#define int LL
using namespace std;
using LL = long long;
const LL LLINF = 9e18;
const int INF = 0x3f3f3f3f;
const int N = 1e5 + 7;
const int M = 1e9 + 7;
int n;
int a[N];
map<int,int,greater<int>> mp;

void solve()
{
    cin >> n;
    for(int i = 1;i <= n;i++)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    int ans = 1;
    int flag = 2;
    for(auto& e : mp)
    {
        if(e.second >= 4 && flag != 1)
        {
            ans = e.first * e.first;
            cout << ans << endl;
            return;
        }
        else if(e.second >= 2)
        {
            ans *= e.first;
            flag--;
        }
        if(flag == 0) break;
    }
    if(flag != 0)
    {
        cout << 0 << endl;
        return;
    }
    cout << ans << endl;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    //cin >> t;
    while(t--)
    {
        solve();
    }
    return 0;
}
